package cn.edkuir.seckill;

import org.springframework.amqp.rabbit.annotation.EnableRabbit;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;

/**
 * 1.整合sentinel:
 *  1) 导入依赖
 *  2) 下载sentinel-dashboard
 *  3) 配置sentinel控制台地址信息
 *      默认所有规则存在于服务器内存中, 重启失效
 *
 * 2.每个微服务导入actuator
 * 3.自定义sentinel的流控返回
 * 4.使用sentinel保护feign的远程调用:
 *      1) 调用方的熔断保护：feign.sentinel.enabled=true
 *      2) 调用方的降级保护：调用方手动指定远程服务的降级策略, 远程服务被降级处理, 触发熔断回调
 *      3) 服务方的降级保护(超大流量)：在服务方(远程服务)指定降级策略
 *
 * 5.自定义受保护资源
 *      1) 代码
 *      try(Entry entry = SphU.entry(resourceName)) {
 *      } catch (BlockException e) {}
 *      2) 注解 @SentinelResource
 */
@EnableRabbit
@EnableFeignClients
@EnableDiscoveryClient
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
@EnableRedisHttpSession
public class MallSeckillApplication {

    public static void main(String[] args) {
        SpringApplication.run(MallSeckillApplication.class, args);
    }

}
